// Decompiled on 周六 2月 22 19:31:49 CST 2025 with Zomboid Decompiler v0.1.3 using Vineflower.
package zombie.util;

import zombie.util.util.Display;
import zombie.util.util.Exceptions;

public abstract class AbstractIntCollection implements IntCollection {
    protected AbstractIntCollection() {
    }

    @Override
    public boolean add(int v) {
        Exceptions.unsupported("add");
        return false;
    }

    @Override
    public boolean addAll(IntCollection c) {
        IntIterator intIterator = c.iterator();
        boolean _boolean = false;

        while (intIterator.hasNext()) {
            _boolean |= this.add(intIterator.next());
        }

        return _boolean;
    }

    @Override
    public void clear() {
        IntIterator intIterator = this.iterator();

        while (intIterator.hasNext()) {
            intIterator.next();
            intIterator.remove();
        }
    }

    @Override
    public boolean contains(int v) {
        IntIterator intIterator = this.iterator();

        while (intIterator.hasNext()) {
            if (intIterator.next() == v) {
                return true;
            }
        }

        return false;
    }

    @Override
    public boolean containsAll(IntCollection c) {
        IntIterator intIterator = c.iterator();

        while (intIterator.hasNext()) {
            if (!this.contains(intIterator.next())) {
                return false;
            }
        }

        return true;
    }

    @Override
    public boolean isEmpty() {
        return this.size() == 0;
    }

    @Override
    public boolean remove(int v) {
        IntIterator intIterator = this.iterator();
        boolean _boolean = false;

        while (intIterator.hasNext()) {
            if (intIterator.next() == v) {
                intIterator.remove();
                _boolean = true;
                break;
            }
        }

        return _boolean;
    }

    @Override
    public boolean removeAll(IntCollection c) {
        if (c == null) {
            Exceptions.nullArgument("collection");
        }

        IntIterator intIterator = this.iterator();
        boolean _boolean = false;

        while (intIterator.hasNext()) {
            if (c.contains(intIterator.next())) {
                intIterator.remove();
                _boolean = true;
            }
        }

        return _boolean;
    }

    @Override
    public boolean retainAll(IntCollection c) {
        if (c == null) {
            Exceptions.nullArgument("collection");
        }

        IntIterator intIterator = this.iterator();
        boolean _boolean = false;

        while (intIterator.hasNext()) {
            if (!c.contains(intIterator.next())) {
                intIterator.remove();
                _boolean = true;
            }
        }

        return _boolean;
    }

    @Override
    public int size() {
        IntIterator intIterator = this.iterator();

        int _int;
        for (_int = 0; intIterator.hasNext(); _int++) {
            intIterator.next();
        }

        return _int;
    }

    @Override
    public int[] toArray() {
        return this.toArray(null);
    }

    @Override
    public int[] toArray(int[] int1) {
        int int0 = this.size();
        if (int1 == null || int1.length < int0) {
            int1 = new int[int0];
        }

        IntIterator intIterator = this.iterator();

        for (int int2 = 0; intIterator.hasNext(); int2++) {
            int1[int2] = intIterator.next();
        }

        return int1;
    }

    @Override
    public void trimToSize() {
    }

    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append('[');

        for (IntIterator intIterator = this.iterator(); intIterator.hasNext(); stringBuilder.append(Display.display(intIterator.next()))) {
            if (stringBuilder.length() > 1) {
                stringBuilder.append(',');
            }
        }

        stringBuilder.append(']');
        return stringBuilder.toString();
    }
}
